<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>商场库</title>
		<link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
	    <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
      <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
      <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
	    <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
	    <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
	    <script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
	    <script type="text/javascript" src="/webapp/js/common/config.js"></script>
    </head>
    <body>
    	   <div class="easyui-container-fluid">
              <div class="easyui-panel" style="border: none;">
                 <div class="nav" id="nav">
                    
                 </div>
                 <div class="easyui-panel" style="padding-top:20px;">
                      <div style="margin-bottom:20px;">
                        <label class="item-label">代码：</label>
                        <input type="text" class="easyui-textbox" name="code" style="width:100px;"/>
                        <label class="item-label">名称：</label>
                        <input type="text" class="easyui-textbox" name="name" style="width:100px;"/>
                        <label class="item-label">渠道：</label>
                        <select class="easyui-combobox" name="channelCode" data-options="panelHeight:'auto'" style="width:100px;">
                          <option value="">-请选择-</option>
                        </select>
                        <label class="item-label">状态：</label>
                        <select class="easyui-combobox" name="entityStatus" data-options="panelHeight:'auto'" style="width:100px;">
                          <option value="">-请选择-</option>
                          <option value="OK">启用</option>
                          <option value="DISABLE">禁用</option>
                        </select>
                        <label class="item-label">类型：</label>
                        <select class="easyui-combobox" name="type" data-options="panelHeight:'auto'" style="width:100px;">
                          <option value="">-请选择-</option>
                          <option value="SUPERMARKET">超市</option>
                          <option value="DEPARTMENT_STORE">百货</option>
                          <option value="PRO_SHOP">家电</option>
                        </select>
                      </div>
                      <div style="margin-bottom:20px;">
                        <label class="item-label">省份：</label>
                        <select class="easyui-combobox" name="province" data-options="panelHeight:'auto',url:'/webserver/dictionary/getDictionaryByType?type=LOCATION_PROVINCE',method:'get',textField:'name',valueField:'id'" style="width:100px;">
                        </select>
                        <label class="item-label">市|县：</label>
                        <select class="easyui-combobox" name="city" data-options="panelHeight:'auto'" style="width:100px;">
                          <option>1</option>
                          <option>2</option>
                        </select>
                        <label class="item-label">隶属城市：</label>
                        <select class="easyui-combobox" name="belongCity" data-options="panelHeight:'auto'" style="width:100px;">
                          <option>启用</option>
                          <option>禁用</option>
                        </select>
                        <label class="item-label">城市级别：</label>
                        <select class="easyui-combobox" name="cityLevelCode" data-options="panelHeight:'auto'" style="width:100px;">
                          <option value="">-请选择-</option>
                          <option value="1">一线城市</option>
                          <option value="2">二线城市</option>
                          <option value="3">三线城市</option>
                          <option value="4">县域城市</option>
                        </select>
                      </div>
                      <div style="margin-bottom:20px;">
                        <label class="item-label">城市规模：</label>
                        <select class="easyui-combobox" name="cityScaleCode" data-options="panelHeight:'auto'" style="width:100px;">
                              <option value="">-请选择-</option>
                              <option value="1">超大</option>
                              <option value="2">特大</option>
                              <option value="3">大</option>
                              <option value="4">中</option>
                              <option value="5">小</option>
                              <option value="6">县城</option>
                        </select>
                        <label class="item-label">添加时间：</label>
                        <input type="date" class="easyui-datetimebox" name="startdate"/>
                        <span>-</span>
                        <input type="date" class="easyui-datetimebox" name="enddate"/>
                      </div>
                      <div style="margin-bottom:20px;text-align:center;">
                        <a class="easyui-linkbutton c8" style="width:80px;" onclick="searchBy()">查询</a>
                      </div>
                      
                 </div>
                 <div class="table-wrapper">
                   <table id="datagrid" class="easyui-datagrid">
                     <thead>
                       <tr>
                         <th data-options="field:'code',align:'center'" width="80">商场代码</th>
                         <th data-options="field:'name',align:'center'" width="120">商场名称</th>
                         <th data-options="field:'channelCode',align:'center'" width="80">渠道代码</th>
                         <th data-options="field:'channelName',align:'center'" width="130">渠道名称</th>
                         <th data-options="field:'provinceName',align:'center'" width="80">省份</th>                 
                         <th data-options="field:'cityName',align:'center'" width="80">市县</th>
                         <th data-options="field:'belongCityName',align:'center'" width="80">城市隶属</th>
                         <th data-options="field:'channelType',align:'center',formatter:typeFormatter" width="80">类型</th>
                         <th data-options="field:'remark',align:'center'" width="160">备注</th>
                         <th data-options="field:'entityStatus',align:'center',formatter:statusFormatter" width="80">状态</th>
                         <th data-options="field:'action',align:'center',formatter:actions" width="160">操作</th> 
                       </tr>
                     </thead>
                     <tbody>
                     </tbody>
                   </table>
                 </div>
              </div>
         </div>
    </body>
    <script type="text/javascript">
        $(function(){
            setNav();
            $("#datagrid").datagrid({
               pagination:true,
               rownumbers:true,
               toolbar:[{
                    text:'添加商场',
                    handler:function(){
                      window.parent.addTab("添加商场","../channel/mall/add.html");
                    }
                }]
           });
           $.ajax({
               url:config.url + "/mall",
               type:"get",
               xhrFields:{withCredentials:true},
               data:{size:10},
               success:function(data){
                  $("#datagrid").datagrid({data:data.content}).datagrid("getPager").pagination({
                    pageList:[10,15,20,25,30,35,40,50,100],
                    displayMsg:"共"+data.totalElements+"条记录"
                  });
               },
               error:function(data){
                  console.log(data);
               }
           });
        });
        function actions(val,row){
            return "<a href='javascript:void(0);' class='easyui-linkbutton l-btn l-btn-small' style='width:60px' "+
         "onclick='edit(\""+row.id+"\")'>修改</a>&nbsp;&nbsp;"+
         "<a href='javascript:void(0);' class='easyui-linkbutton l-btn l-btn-small' style='width:60px' "+
         "onclick='disableOne(\""+row.id+"\")'>禁用</a>";
        }
        function edit(id){
          window.location.href = "./add.html?id="+id;
     }
     function disableOne(data){
          $.messager.confirm("提示","您确定禁用该记录吗？",function(flag){
               if(flag){
                  $.ajax({
                      url:config.url+"/mall/"+data,
                      type:'DELETE',
                      xhrFields:{withCredentials:true},
                      success:function(data){
                          $.messager.alert("提示","操作成功");
                          $.ajax({
                             url:config.url + "/mall",
                             type:"get",
                             data:{size:10},
                             xhrFields:{withCredentials:true},
                             success:function(data){
                                $("#datagrid").datagrid({data:data.content}).datagrid("getPager").pagination({
                                  pageList:[10,15,20,25,30,35,40,50,100],
                                  displayMsg:"共"+data.totalElements+"条记录"
                                });
                             },
                             error:function(data){
                                console.log(data);
                             }
                         });
                      },
                      error(XMLHttpRequest,textStatus,thrown){

                      }
                  });
               }
          });
     }

     function searchBy(){
        var data = getFormData(document.getElementById("ff"));
        $.ajax({
             url:config.url + "/mall",
             type:"get",
             data:transfer(data),
             xhrFields:{withCredentials:true},
             success:function(data){
                $("#datagrid").datagrid({data:data.content}).datagrid("getPager").pagination({
                  pageList:[10,15,20,25,30,35,40,50,100],
                  displayMsg:"共"+data.totalElements+"条记录"
                });
             },
             error:function(data){
                console.log(data);
             }
         });
     }
     function typeFormatter(type){
       var res = "";
       switch(type){
         case "SUPERMARKET":
            res = "超市";
            break;
         case "DEPARTMENT_STORE":
            res="百货";
            break;
         case "PRO_SHOP":
            res="家电";
            break;
         default:
            res="超市";
       }
       return res;
     }
    </script>
</html>